﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using LastStand.gameContent.Friendlies;
using System.Collections.Generic;

namespace LastStand.gameContent
{
	/* Structure class is the base class for the player's upgradable structures.
	 * Structures hold friendly game objects, which assist the player in
	 * fucking up the enemy. Structures can only hold so many friendlies,
	 * determined by the inherited structure classes. They have health too.
	 * 
	 * -------------------------------------------------------------------------------
	 * 
	 * EXAMPLE - HOW TO USE THIS ABSTRACT CLASS FOR CREATING DERIVED STRUCTURE CLASSES:
	 * 
	 * public class RifleTower : Structure
	 * {
	 *		public RifleTower(Vector2 spawn)
	 *		{
	 *			//initialize maxOccupants first. I made maxoccupants 1 in this instance
	 *			//because we have 5 levels of upgrades that the structure will be able to
	 *			//be upgraded to. Consider that when the rifletower has been fully upgraded, it would have
	 *			//a max capacity of 5 friendlies. To me, 5 friendlies seemed logical for a rifletower.
	 *			//a bunker might be able to hold a bit more than that (lets say 10), maybe in that case MaxOccupants
	 *			//would be initialized in it's constructor to 5, therefore when it's fully upgraded it will
	 *			//hold ten friendlies. Ask me about this.
	 *	
	 *			//So as psuedocode: Final Max Occupants = initial max occupants + maximum upgrade Level
	 *			//in this case: 5 = 1 + 4
	 *			MaxOccupants = 1;
	 *			
	 *			//INITIALIZE LISTS or you get awesome errors
	 *			occupants = new List<Friendly>();
	 *			
	 *			//initalize your MaxOccupants. 
	 *			MaxOccupants = 1;
	 *			
	 */
	public class Structure : Sprite
	{
		//the list of friendly occupants in the structure.
		private List<Friendly> occupants;

		public List<Friendly> GetOccupants
		{
			get { return this.occupants; }
		}

		//pretty straight forward. Changes w/ upgrade level.
		private int maxOccupants;

		protected int MaxOccupants
		{
			set { this.maxOccupants = value; }
		}

		public int GetMaxOccupants
		{
			get { return this.maxOccupants; }
		}

		/* UPGRADE LEVEL WILL INCREASE MAXOCCUPANTS BY 1 FRIENDLY AND
		 * IT WILL INCREASE HEALTH BY 50 POINTS PER LEVEL.
		 * 
		 * UPGRADE LEVEL BEGINS AT 0, ENDS AT 4. Leaves us with
		 * 5 levels, [1-5] written to the screen for less confusion to
		 * players. But the default upgradeLevel will ALWAYS BE ZERO.
		 */
		private int upgradeLevel = 0;

		protected int UpgradeLevel
		{
			set { this.upgradeLevel = value; }
		}

		public int GetUpgradeLevel
		{
			get { return this.upgradeLevel; }
		}

		//health for the structure. Changes w/ upgrade level.
		private float health;

		protected float Health
		{
			set { this.health = value; }
		}

		public float GetHealth
		{
			get { return this.health; }
		}

		//these two methods are where the Friendlies are handled
		//and put "into" these structures and taken "out".
        public virtual void addFriendly(Friendly f) { }

        public virtual void removeFriendly(Friendly f) { }

		//the function where the structure loses health from a shot
		//hitting it.
		protected void takeDamage(Shot s)
		{
			//negate this structure's health determined by the shot's damage
			this.health -= s.Damage;
		}
	}
}
